package com.linux.huhx.xstream;

import com.thoughtworks.xstream.XStream;

/**
 * Created by huhx on 2017-07-18.
 */
public class XstreamMain {

    public static void main(String[] args) {
        XStream xstream = new XStream();
//        XStream xstream = new XStream(new StaxDriver());
        xstream.alias("person", Person.class);

        Person joe = new Person("Liu", "Ling");
        joe.setPhone(new PhoneNumber(155, "1234-456"));
        joe.setFax(new PhoneNumber(271, "9999-999"));

        String xml = xstream.toXML(joe);
        System.out.println(xml);

        Person person = (Person) xstream.fromXML(xml);
        System.out.println(person.getFirstname());
    }
}
